﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace InfiniDrive
{

    /// <summary>
    /// Contains all the data about a single file or folder
    /// </summary>
    [Serializable]   
    public class VirtualFSInfo
    {
        #region Private Fields
        // private byte[] _fileData;        
        private string fileName;        
        private long fileSize;        
        private string fileEncoding;
        private string fileExtension;
        // private string partID;
        private int chunkID;
        private int totalChunks;
        private string fullPath;
        private bool isFolder;
        private DateTime creationTime;
        private DateTime modifiedTime;
        // private string fileType;
        // private ChunckMapping chunkMapping; // Where to find all the chunks
 
        #endregion

        #region Public Properties
        
        /// <summary>
        /// The content-type of the file 
        /// </summary>
        public string FileExtension
        {
            //@ get; set;
            get { return fileExtension; }
            set { fileExtension = value; }
        }
        /* /// <summary>
        /// The array of bytes that comprise the file
        /// </summary>
        public byte[] FileData
        {
            // get { return fileData; }
            // set { fileData = value; }
        } */

        /// <summary>
        /// The name of the file
        /// </summary>
        public string FileName
        {
            //@ get; set;
            get { return fileName; }
            set { fileName = value; }
        }

        /// <summary>
        /// The size of the file
        /// </summary>
        public long FileSize
        {
            //@ get; set;
            get { return fileSize; }
            set { fileSize = value; }
        }

        /// <summary>
        /// The encoding method of the file
        /// </summary>
        public string FileEncoding
        {
            //@ get; set;
            get { return fileEncoding; }
            set { fileEncoding = value; }
        }

        /// <summary>
        /// The chunk id 
        /// </summary>
        public int ChunkID
        {
            //@ get; set;
            get { return chunkID; }
            set { chunkID = value; }
        }
        
        /// <summary>
        /// The total number of chunks
        /// </summary>
        public int TotalChunks
        {
            //@ get; set;
            get { return totalChunks; }
            set { totalChunks = value; }
        }

        /// <summary>
        /// The full path of a file or folder
        /// </summary>
        public string FullPath
        {
            //@ get; set;
            get { return fullPath; }
            set { fullPath = value; }
        }
        
        /// <summary>
        /// Is object a folder 
        /// </summary>
        public bool IsFolder
        {
            //@ get; set;
            get { return isFolder; }
            set { isFolder = value; }
        }

         /// <summary>
        /// The creation time of a file
        /// </summary>
        public DateTime CreationTime
        {
            //@ get; set;
            get { return creationTime; }
            set { creationTime = value; }
        }

        /// <summary>
        /// Last modified time of a file
        /// </summary>
        public DateTime ModifiedTime
        {
            //@ get; set;
            get { return modifiedTime; }
            set { modifiedTime = value; }
        }
        #endregion

        #region CTOR
        /// <summary>
        /// Default Constructor
        /// </summary>
        public VirtualFSInfo() { }

        /// <summary>
        /// Constructor using FileInfo
        /// </summary>
        public VirtualFSInfo(FileInfo f) 
        {
            fileName = f.Name;
            fileSize = f.Length;
            fileExtension = f.Extension;
            fullPath = f.FullName;
            creationTime = f.CreationTime;
            modifiedTime = f.LastWriteTime;
            isFolder = false;
        }

        /// <summary>
        /// Constructor using DirectoryInfo
        /// </summary>
        public VirtualFSInfo(DirectoryInfo d)
        {
            fileName = d.Name;
            fileSize = 0;
            fileExtension = null;
            fullPath = d.FullName;
            creationTime = d.CreationTime;
            modifiedTime = d.LastWriteTime;
            isFolder = true;
        }
        #endregion

        #region Methods

        #endregion

        #region Overrides
        /// <summary>
        /// Returns the filename of this attachment object
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            return fileName;
        }
        #endregion
    }
}
